import QtQuick 1.1
import com.meego 1.0
import "CommomUtil.js" as Util
import "Modulelib.js" as ModuleUtil
import "Citys.js" as CityUtil

ListModel {
    id: container

    function getData(){
        Util.getXmlStringByUrl(ModuleUtil.getDealerInfoUrl(CityUtil.getCurrentCityId()), dealerInfoCallback);
    }

    function dealerInfoCallback(responseXml){
        var a = responseXml.documentElement;
        var dealerId = 0; var dealerName = ""; var dealerSimName = ""; var dealerAddr = ""; var dealerPhone = "";
        var dealerKindId = 0; var dealerKindName = ""; var dealerPrice = 0; var dealerP = 0; var dealerPTime = "";
        for(var i = 0; i < a.childNodes[0].childNodes.length; ++i){
            if(a.childNodes[0].childNodes[i] !== null && a.childNodes[0].childNodes[i].childNodes.length > 9){
                dealerId = a.childNodes[0].childNodes[i].childNodes[0].childNodes[0].nodeValue;
                dealerName = a.childNodes[0].childNodes[i].childNodes[1].childNodes[0].nodeValue;
                dealerSimName = a.childNodes[0].childNodes[i].childNodes[2].childNodes[0].nodeValue;
                dealerAddr = a.childNodes[0].childNodes[i].childNodes[3].childNodes[0].nodeValue;
                dealerPhone = a.childNodes[0].childNodes[i].childNodes[4].childNodes[0].nodeValue;
                dealerKindId = a.childNodes[0].childNodes[i].childNodes[5].childNodes[0].nodeValue;
                dealerKindName = a.childNodes[0].childNodes[i].childNodes[6].childNodes[0].nodeValue;
                dealerPrice = a.childNodes[0].childNodes[i].childNodes[7].childNodes[0].nodeValue;
                dealerP = a.childNodes[0].childNodes[i].childNodes[8].childNodes[0].nodeValue;
                dealerPTime = a.childNodes[0].childNodes[i].childNodes[9].childNodes[0].nodeValue;
                container.append({"dealerId" : dealerId,"dealerName":dealerName,"dealerSimName":dealerSimName,"dealerAddr":dealerAddr,
                                 "dealerPhone":dealerPhone,"dealerKindId":dealerKindId,"dealerKindName":dealerKindName,"dealerPrice":dealerPrice,
                                 "dealerP":dealerP,"dealerPTime":dealerPTime});
            }
        }
        loading.finish()
    }
}
